package com.xxx.state;

/**
 * @version v1.0
 * @Description
 * @Author admin
 * @date 2021/7/30  15:15
 * @Copyright
 */
public class WatitDome {
    public static Object obj = new Object();

    public static void main(String[] args) {//Threand-0
        new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized (obj) {
                    System.out.println(Thread.currentThread().getName() + "-A");
                    try {
                        obj.wait();//释放锁
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName() + "-B");
                }
            }
        }).start();
//        try {
//            Thread.sleep(1000);//不释放锁
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        synchronized (obj) {
            System.out.println(Thread.currentThread().getName() + "-c");
            obj.notify();
        }

    }
}
